<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="./include/tag.jsp" %>
<%
    String path = request.getContextPath();
    String basePath = request.getServerName() + ":"
            + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="zh">
<html>
<head>
    <%@include file="./include/commonFile.jsp" %>
    <title>Title</title>
</head>
<body>
    <button type="button" id="send">send</button>
</body>

<script>
    var path = '<%=basePath%>';
    var websocket;
    if ('WebSocket' in window) {
        websocket = new WebSocket("ws://" + path +"ws.do");
    } else if ('MozWebSocket' in window) {
        websocket = new MozWebSocket("ws://" + path +"ws.do");
    } else {
        websocket = new SockJS("http://" + path +"ws/sockjs.do");
    }
    websocket.onopen = function(event) {
        console.log("WebSocket:已连接");
        console.log(event);
    };
    websocket.onmessage = function(event) {
        console.log("WebSocket:收到一条消息",event.data);
    };
    websocket.onerror = function(event) {
        console.log("WebSocket:发生错误 ");
        console.log(event);
    };
    websocket.onclose = function(event) {
        console.log("WebSocket:已关闭");
        console.log(event);
    }

    $('#send').on('click', function () {
        $.get('${ctx}/test/2/send.do', function (res) {

        });
    })
</script>
</html>
